<template>
  <div class="login">
    <h1>慧用劵管理系统</h1>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="用户名" prop="name">
        <el-input v-model="ruleForm.name"></el-input>
      </el-form-item>

      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model="ruleForm.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login()">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import apiAll from "@/common/apiAll";
//导出
export default {
  name: "login",
  data() {
    return {
      ruleForm: {
        name: '',
        password: '',
      },
      rules: {
        name: [
          {required: true, message: '请输入管理用户名', trigger: 'blur'},
          {min: 3, max: 10, message: '长度在 3 到 10个字符', trigger: 'blur'}
        ],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
          {min: 3, max: 10, message: '长度在 3 到 10个字符', trigger: 'blur'}
        ],
      }
    }
  },
  methods: {
    login() {

      let params = {
        username: this.ruleForm.name,
        password: this.ruleForm.password
      }
      apiAll.login(params).then(res => {
        console.log(res);
      })

      // let params1 = {
      //   page_no: 1,
      //   page_size: 20
      // }
      // apiAll.getDdxMtOrder(params1).then(res => {
      //   console.log(res);
      // })

      /*
      let {name, password} = this.ruleForm;
      this.$http({
        method: 'post',
        url: '/v1/auth/login/',
        data: {username: name, password: password}
      }).then(res => {
        console.log(res);
        let code = res.status;
        if (code == '200') {
          sessionStorage.setItem('username', name);
          //密码正确，页面跳转
          // this.$router.push('/pageHome');
        }
      })*/
    }
  }
};
</script>


<style scoped>

</style>
